﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Windows.Forms;
using System.IO;
using Swoosh.Contracts.MediaPlayerLib;
using System.Xml;

namespace Swoosh.Contracts.MediaPlayerLib
{
    [Serializable]
    public class SwooshConfig
    {
        private static SwooshConfig _CurrentConfig;
        [XmlIgnore]
        public static SwooshConfig CurrentConfig
        {
            get { return _CurrentConfig; }
            set { _CurrentConfig = value; }
        }

        private List<Storage> _StorageList;
        public List<Storage> StorageList
        {
            get { return _StorageList; }
            set { _StorageList = value; }
        }


        private List<SwooshAction> _SwooshActionList;
        public List<SwooshAction> SwooshActionList
        {
            get { return _SwooshActionList; }
            set { _SwooshActionList = value; }
        }

        private List<PlaybackDevice> _PlaybackDevices;
        public List<PlaybackDevice> PlaybackDevices
        {
            get { return _PlaybackDevices; }
            set { _PlaybackDevices = value; }
        }
        

        private List<IPlaybackDevice> _IPlaybackDevices;
        [XmlIgnore]
        public List<IPlaybackDevice> IPlaybackDevices
        {
            set
            {
                _IPlaybackDevices = value;
            }
            get
            {
                return _IPlaybackDevices;
            }
        }

        public SwooshConfig()
        {            
            _StorageList = new List<Storage>();
            _SwooshActionList = new List<SwooshAction>();
            _IPlaybackDevices = new List<IPlaybackDevice>();
        }

        public static void SerializeConfig(SwooshConfig Config, string Filename)
        {
            XmlSerializer x = new XmlSerializer(typeof(SwooshConfig));
            x.Serialize(new StreamWriter(Filename, false), Config);            
        }

        public static SwooshConfig DeSerializeConfig(StringReader xml)
        {
            SwooshConfig Config = new SwooshConfig();

            XmlSerializer x = new XmlSerializer(typeof(SwooshConfig));
            Config = (SwooshConfig)x.Deserialize(xml);

            return Config;
        }
    }

    public class PlaybackDevice
    {
        public string Name { get; set; }
        
        public string StorageName { get; set; }

        public string PlayerClass { get; set; }

        public string Configuration { get; set; }
    }


}
